/*
 * Track.h
 *
 *  Created on: 04/10/2011
 *      Author: solnox
 */

#ifndef TRACK_H_
#define TRACK_H_

#include "opencv2/opencv.hpp"
#include <QtCore>

struct TrackDetail {
    int cameraIdx;
    int keypointIdx;
    float x;
    float y;
};

class Track {
public:
	/*struct unique_keypoint_id{
		unsigned int image_id;
		unsigned int kp_id;
	};*/
	Track();
	Track(unsigned int image_id, unsigned int kp_id);
	virtual ~Track();
	void addKeypoint(unsigned int image_id, unsigned int kp_id);
	void addKeypoint(QPair<unsigned int, unsigned int> ukp_id);
        bool isInconsistent(){return is_inconsistent_;}
        unsigned int size(){return track_.size();}
        void getImageIDs(QList<unsigned int> & list2fill);
        cv::Mat get3DPoint(){return point3D_;}
        void set3DPoint(cv::Mat&  point3D){point3D_ = point3D.clone();is_init_=true;}
        void setIsInit(){is_init_=true;}
        bool isInit(){return is_init_;}
        unsigned int getKeyPointID(unsigned int img_id);
        QVector<QPair<unsigned int, unsigned int> > getTrack(){return track_;}
        void printImgIds();
        bool isVisible(unsigned int img_id);
        void setInconsistent(){is_inconsistent_=true;}
        bool containsTrackDetails(unsigned int id);
        cv::Point2f getKeyPoint(unsigned int id);

        QList<TrackDetail> track_details;

        QVector<QPair<unsigned int, unsigned int> > track_;

private:


        // QPair<unsigned int, unsigned int>  -> imgid,keypointid
	bool is_inconsistent_;
	void checkAndSetInconsitent(QPair<unsigned int, unsigned int> ukpid);
        cv::Mat point3D_;
        bool is_init_;


};

#endif /* TRACK_H_ */
